import { memo } from 'react';
import { Bubble } from '@ant-design/x';

import Icon from '@/component/Icon';
import RobotIcon from '@/view/home/component/MessageHistory/RobotMessage/RobotIcon';

export type RetryCb = (question: string) => void;

export default memo(function Error(props: {
    retry: RetryCb;
    question: string;
}) {
    return (
        <Bubble
            placement="start"
            content={
                <section>
                    <span>服务异常, 请重试！</span>
                    <Icon
                        onClick={() => props.retry(props.question)}
                        name="retry text-red-400 font-bold"
                        active={true}
                    />
                </section>
            }
            avatar={<RobotIcon />}
        />
    );
});
